package com.filiebo.demo.charact1;

import com.google.common.util.concurrent.ThreadFactoryBuilder;

import java.util.concurrent.*;

public class ThreadSimple {

    private static ThreadFactory writeThreadFactory = new ThreadFactoryBuilder().setNameFormat("Thread-Pool-%d").build();

    private static ExecutorService singleThreadPool = new ThreadPoolExecutor(1,10,0L,
            TimeUnit.MILLISECONDS,new LinkedBlockingDeque<>(1024),writeThreadFactory,new ThreadPoolExecutor.AbortPolicy());


    private static ExecutorService executor = new ThreadPoolExecutor(10, 10,
            60L, TimeUnit.SECONDS,
            new ArrayBlockingQueue(10));


    public static void main(String[] args) {
        ThreadDemo threadDemo = new ThreadDemo();

        singleThreadPool.execute(threadDemo::threadDemo1);
        
        singleThreadPool.execute(threadDemo::threadDemo2);




//        Thread t1 = new Thread(()->{
//           threadDemo.threadDemo1();
//        });
//
//        Thread t2 = new Thread(()->{
//            threadDemo.threadDemo2();
//        });

//        t1.start();
//        t2.start();

        while (true){
            System.out.println(Thread.currentThread().getName()+"正在执行");
        }





    }

}
